Skip to content

Fix link patterns inside wrapped Markdown labels - #747

Merged
nicholasserra merged 2 commits into
trentm:masterfrom
nk-batman21:fix-multiline-link-patterns
Oct 27, 2026
Merged

nicholasserra merged 2 commits into
trentm:masterfrom
nk-batman21:fix-multiline-link-patterns

Conversation

@nk-batman21

Copy link
Copy Markdown
Contributor

With link-patterns enabled, a wrapped Markdown link label can gain a nested anchor. An image with a wrapped alt label can instead display escaped anchor markup in its alt text.

Let the existing inline-link exclusion span label newlines, bounded by the core link parser's label limit. Extend the Markdown syntax fixture with wrapped links, images, nested brackets, and automatic links before and after them.

  • Ran: full native test suite, 296 tests on Python 3.9, 3.13, and 3.14 with all optional dependencies.
  • Ran: python test/test_redos.py, 12 tests.
  • Checked: new fixture fails before the fix; 168 link/image comparisons and changed-line PEP8 pass.

@Crozzers Crozzers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog also needs updating

Comment thread README.md Outdated
@Crozzers

Copy link
Copy Markdown
Contributor

LGTM if tests pass

@nicholasserra
nicholasserra merged commit ca42f2d into trentm:master Oct 27, 2026
26 of 36 checks passed
@nk-batman21

Copy link
Copy Markdown
Contributor Author

@Crozzers thanks for merging. The wiki only takes edits from collaborators, so here is the note I mentioned for the link-patterns page, for example just before "Default link behaviour":

## Text inside Markdown links

The extra doesn't link text that is already the label of an inline Markdown
link or image, such as `[see recipe 123](https://example.com)` or
`![bug 234](bug.png)`, including when the label wraps onto another line.
Only text outside such links is matched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants